:
publicvoidexit(intcode){
System.exit(code);
}
Therefore, to write a multi-threaded Junit test case, the main thread must wait for all sub-threads to complete the execution before exiting. The method is the join method in the Thread. Then again, is there no third-party package support for such a simple and typical requirement? Through google, I quickly found GroboUtils, an open-source thir
Eclipse comes with the JUnit plug-in, which makes it easy to write test cases in a project without having to install them.Add a JUnit library to your projectBefore you can write test cases, you need to introduce
Eclipse comes with the JUnit plug-in, which makes it easy to write test cases in a project without having to install them.Add a JUnit library to your projectBefore you can write test cases, you need to introduce
overall structure of the project
Create a JUnit Testcase
Create a new JUnit TestCase class under the Test/java package directory, as follows:
Applyrequestspeedv3test.java
Package com.yirendai.borrowbase.node.applyrequest.yrd.fast3;
Import Com.yirendai.borrowbase.api.ServiceResult;
Import Com.yirendai.borrowbase.api.applyrequest.IApplyRequestSpeedV3Facade;
Import
target = "EmployeeInfo"; String result = worddealutil.wordformat4db (target); Assertequals ("Employee_info", result); }//test the case when the tail letter is uppercase @Test public void Wordformat4dbend () {String target = "Employeeinfoa"; String result = worddealutil.wordformat4db (target); Assertequals ("employee_info_a", result); }//When testing multiple connected letters capitalized @
Junit Test @ test red name problem, junit Test @ test
Prepare for testing. For example, all are named Red.
Ctrl + 1 or move the cursor over @ Test
Place the cursor on @
. println ("thread 1:" + threadName); latch. await (); // The blocking wait count is 0 System. out. println ("thread 1:" + threadName);} catch (InterruptedException e) {e. printStackTrace ();} System. out. println ("num =" + this. getNumber ());}}}2. Execution result
The result of Junit execution is as follows:
Thread 1: t1
Or nothing is printed.
The main execution result is as follows:
Thread 1: t1 Thread 0: t2 thread 1: t1num = 1
When t1 is executed
JUnit unit test (1) -- JUnit Introduction
1. JUnit Introduction
JUnit is a Java testing framework for source code development. It is used to write and run reusable tests. It is an example of xUnit, a unit testing framework system (for java ). It is mainly used for white box
Unit test framework junit, unit test junit
# Unit test junit* Define a class that inherits AndroidTestCase. Define a method in the class to test this method.
* When specifying the comma
:
package Calculate;public class Calculate { public int add(int a,int b){ return a+b; } public int minus(int a,int b){ return a-b; }}
Right-click the current class and create a Junit test case. This is the test case. For Development, we can create many corresponding test
assertion methods provided by JUnit that judge whether the test results are correct (in class Org.junit.Assert), and we use it to compare the execution result to the expected value "Employee_info". To determine if the test was successful.See how the results work. Right-click on the test class and select Run as
JUnit unit test (2) -- JUnit Basics
1. Basic Introduction
1. JUnit is a framework for testing code. The purpose of testing is to ensure that the Code is correct, rather than the code is correct.
2. The test class should not be put together with the target class, but the comp
JUnit Unit Test Tutorial-The ultimate guide
The ultimate guide to JUnit Unit Testing tutorials
Description
Introduction to Unit Testing
1 What is unit testing
2 Test coverage
3 unit tests in Java
About JUnit
Junit 4 allows you to run test classes in bulk by using test suite classes. To create a test suite for a set of test classes, add the following annotations for the test class:
@RunWith (Suite.class) @SuiteClasses (Testclass1.class
Recently, at the request of the boss, study the spring test related things, and strive to make a convenient use of testing tools, for a spring is not familiar to the JUnit people this is a big pit, swept aside spring test document did not feel any gain, What spring does is just context-sensitive, and the main entrance I want is
Why do you write unit tests?Enterprise development, regardless of the size of the project are inseparable from testing, including unit testing, regression testing, performance testing and so on, and unit testing is to verify that the programmer is the correct way to write code, in the day-to-day development of unit testing is very necessary, imagine if you are developing a huge project, If each of the business logic written by the deployment to the server to run the program through the front int
Label:First of all, I would like to explain that the user registration action in the method does not make any judgment can be registered, nothing to consider, even if all is empty, he can register successfully. If you want to write a test case, follow my steps, useraction In The register () method to add some judgment, and in the JSP page to give the corresponding hint, because there are too many loopholes, I wrote only one judgment-if the user name i
Spring Boot Junit unit test
The old Junit technology is nothing more than to mention, to some extent, to illustrate its importance in the project.Based on my own feelings and experience, the Junit Use Cases Written completely in the project to cover most of the Business Code
field of automated testing, for the same unit of testing, often there are multiple test cases, at the code level, the implementation of multiple test cases, characterized by: the same logic, the data is different. In this case, it is necessary to use the parameterized operation, to some extent to achieve the separatio
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.